Ext.define('Jee.store.JeeStore',{
	extend:'Ext.data.Store',
	 pageSize: 2,
     options :{},
	 autoLoad: false,
	 jeeRequest:null,
     proxy: Ext.create('Jee.data.JeeAjaxProxy'),
     load: function(jeeRequest) {
    	 this.loadPageNo(jeeRequest,1);
     },
	 loadPageNo: function(jeeRequest,page) {	
	     var me = this,operation;
	     me.currentPage = page;
	     var options = this.options;
	     jeeRequest = jeeRequest ||{};
	     if (Ext.isFunction(options)) {
            options = {
                callback: options
            };
        }
	    var data ={};
        Ext.apply(options, {
            groupers: me.groupers.items,
            page: me.currentPage,
            start: (me.currentPage - 1) * me.pageSize,
            limit: me.pageSize,
            addRecords: false
        });
	    data.pageNo = options.page;
	    data.pageSize = options.limit;
	    
	    Ext.applyIf(options, {
	        action : 'read',
	        filters: me.filters.items,
	        sorters: me.getSorters()
	    });
	    
	    Ext.apply(jeeRequest.data,data);
	    operation = Ext.create('Ext.data.Operation', options);
	    operation.jeeRequest = jeeRequest;
	    this.jeeRequest = jeeRequest;
	    if (me.fireEvent('beforeload', me, operation) !== false) {
	        me.loading = true;
	        me.proxy.read(operation, me.onProxyLoad, me);
	    } 
	    return me;
	},
	loadPage: function(page,options) {
        var me = this;
        options = Ext.apply({}, options);
        this.loadPageNo(this.jeeRequest,page);
    },
});